/* 
 * $Id$
 *
 * UMKC Robotics 2009
 *
 * Ryan Boyd (rmb972@umkc.edu / boydkuhawks@gmail.com)
 *
 *
**/

#ifndef TWOSPACE_H
#define TWOSPACE_H

#include "intdefs.h"

#define PI 3.1415926536

typedef struct two_d {
  Float_T a;  /* x in rectangular, r in polar */
  Float_T b;  /* y in rectangluar, a in polar */
} TwoD;

/* a point on a 2d rectangular graph */
typedef struct rectangular_point {
  Float_T x;
  Float_T y;
} RectangularPoint;

/* a point in 2space that is in polar coordinates  */
typedef struct polar_point {
  Float_T r;	/* radial coordinate */
  Float_T a; 	/* angular coordinate */
} PolarPoint;

/* gee, a triangle */
typedef struct triangle {

  Float_T a; /* y-value */
  Float_T b; /* x-value */
  Float_T c; /* hypotenuse, distance, slope */
  Float_T A; /* angle opposite a, usually 'theta'*/
  Float_T B; /* angle opposite b, usually 'gamma' */
  Float_T C; /* angle opposite hypotenuse */

} Triangle;


/* intarface for all user 2space manipulations. */ 
typedef struct twodops {

  /* deal with your universal position */
  RectangularPoint (*u_rp_getpos)(TwoD*);
  void (*u_rp_setpos)(TwoD*, RectangularPoint*);
  PolarPoint (*u_pp_getpos)(TwoD*);
  void (*u_pp_setpos)(TwoD*, PolarPoint*);

  /* conversions */
  RectangularPoint (*rp_from_polar)(PolarPoint*);
  PolarPoint (*pp_from_rect)(RectangularPoint*);
  Float_T (*deg2rad)(Float_T);
  Float_T (*rad2deg)(Float_T);

  /* computations on the triangle */
  void (*t_reset)(Triangle*);
  void (*t_set_a)(Triangle*, Float_T);
  void (*t_set_b)(Triangle*, Float_T);
  void (*t_set_c)(Triangle*, Float_T);
  void (*t_set_A)(Triangle*, Float_T);
  Float_T (*t_A_from_tanInv)(Triangle*);
  Float_T (*t_b_from_ccosA)(Triangle*);
  Float_T (*t_a_from_csinA)(Triangle*);
  Float_T (*t_c_from_distanceFormula)(Triangle*);
  

} TwoDOps;

#endif
